import{ut as e}from"./B603vO-13smUKN.js";import{t}from"./CvEJN-vi4hXmWG.js";import{D as n,E as r,On as i,St as a,_ as o,b as s,bt as c,g as l,k as u,mt as d,o as f,qt as p,tr as m,v as h,vn as g,xt as _,y as v}from"./CIxmKYxc4tZcJF.js";import{k as y}from"./DcwiUW8R1GKRvl.js";import{i as b,n as x}from"./CV1Qssq_3vcbC7.js";import{t as S}from"./DhtdLMWurC5tl.js";import{t as C}from"./CIW45PU32cGxlW.js";import{t as w}from"./O-hPVzDj49oyxE.js";import{i as T,n as E,o as D}from"./BVvRFS7mRz5uC.js";import{a as O,i as k,n as A}from"./D6qfi2N61QUWEz.js";import{a as j,o as M}from"./BbxvatETxeTHf.js";import{t as N}from"./CRaeVofMES4wD.js";import"./C3Xax3Tz4BagVD.js";import{t as P}from"./DlpkIUzkqr8f6.js";import{t as F}from"./B7K2vhSg3J9hjy.js";var I=u({__name:`app-link`,props:{workspace:{type:[String,Boolean]},page:{},pageId:{},name:{},test:{type:[String,Boolean]}},setup(e){let t=e,n=l(()=>{if(t.workspace===!0)return{name:`workspace`,params:{workspaceId:M.workspace?.id}};if(t.name)return{name:t.name};if(typeof t.test==`string`)return{name:t.test?t.test:`test`};let e=t.workspace?t.workspace:M.workspace?.id;return e?{name:`workspace`,params:{workspaceId:e,itemId:t.page,subId:t.pageId}}:{name:`home`}});return(e,t)=>{let r=a(`router-link`);return d(),h(r,{to:n.value},{default:p(()=>[_(e.$slots,`default`)]),_:3},8,[`to`])}}}),L={class:`_center`},R={class:`_itemContainer`},z=[`tooltip`,`onClick`],B=[`tooltip`,`onClick`],V={key:1},H={key:2},U={key:3,class:`_error`},W={key:4},G={href:`https://doocs.space/downloads/macos/latest`,download:``,class:`_download _withIcon`},K={class:`_version`},q=`/logo.svg`,J=u({__name:`app-page-start`,setup(a){let l=e(`start`),u=g(``),_=typeof window<`u`&&`showDirectoryPicker`in window;async function J(){u.value=``;try{let e=window.showDirectoryPicker;if(!e)throw Error(`FileSystem Access API not available in this browser`);let n=await e({mode:`readwrite`});if(!await D(n,`readwrite`)){u.value=j(`settings.storage.permissionNeeded`);return}let r=await E().openFromFolder(n);t({title:r.created?j(`start.folderCreated`):j(`start.folderOpened`),message:n.name}),await P.workspace(r.wid)}catch(e){if(e.name===`AbortError`)return;u.value=e.message,l.warn(`pick folder failed`,e)}}function Y(e){confirm(j(`start.deleteConfirm`))&&T.removeWorkspace(e)}async function X(e){let t=await A(e),n=await x(j(`settings.workspace.labelTitle`),t?.localTitle??``);if(n==null)return;let r=await O(e,{localTitle:n.trim()||void 0});M.workspaces[e]={id:e,title:k(r)}}async function Z(){if(!confirm(j(`start.deleteAllConfirm`)))return;await T.closeWorkspace();try{localStorage.removeItem(`lastWorkspaceId`)}catch{}for(let e of Object.keys(M.workspaces))delete M.workspaces[e];let e=await globalThis.indexedDB?.databases?.()??[];await Promise.all(e.filter(e=>e.name?.startsWith(`zeed-workspace:`)).map(e=>new Promise(t=>{let n=indexedDB.deleteDatabase(e.name);n.onsuccess=n.onerror=n.onblocked=()=>t()}))),location.reload()}return(e,t)=>(d(),h(F,{"hide-navigation":``},{default:p(()=>[o(`div`,L,[o(`p`,null,[o(`img`,{src:q,width:`64`})]),o(`h1`,null,m(e.$t(`start.title`)),1),Object.keys(i(M).workspaces).length?(d(),s(f,{key:0},[o(`p`,null,m(e.$t(`start.choose`)),1),o(`div`,R,[(d(!0),s(f,null,c(Object.values(i(M).workspaces??{}),({id:t,title:a})=>(d(),s(`div`,{key:t,class:`_item`},[n(I,{workspace:t},{default:p(()=>[r(m(a||e.$t(`unnamed`)),1)]),_:2},1032,[`workspace`]),n(i(b)),o(`button`,{tooltip:e.$t(`settings.workspace.labelTitle`),onClick:e=>X(t)},[n(i(C))],8,z),o(`button`,{tooltip:`Removes local copy of ${a}`,onClick:e=>Y(t)},[n(i(w))],8,B)]))),128))])],64)):(d(),s(`p`,V,m(e.$t(`start.emptyInfo`)),1)),o(`p`,null,[n(i(S),{onClick:t[0]||=e=>i(P).create()},{default:p(()=>[r(m(e.$t(`start.create`)),1)]),_:1})]),i(_)?(d(),s(`p`,H,[n(i(S),{onClick:J},{default:p(()=>[r(m(e.$t(`start.openFolder`)),1)]),_:1})])):v(``,!0),u.value?(d(),s(`p`,U,m(u.value),1)):v(``,!0),i(y)?v(``,!0):(d(),s(`p`,W,[o(`a`,G,[t[2]||=o(`svg`,{preserveAspectRatio:`xMidYMid meet`,viewBox:`0 0 24 24`},[o(`path`,{fill:`currentColor`,d:`M17.05 20.28c-.98.95-2.05.8-3.08.35c-1.09-.46-2.09-.48-3.24 0c-1.44.62-2.2.44-3.06-.35C2.79 15.25 3.51 7.59 9.05 7.31c1.35.07 2.29.74 3.08.8c1.18-.24 2.31-.93 3.57-.84c1.51.12 2.65.72 3.4 1.8c-3.12 1.87-2.38 5.98.48 7.13c-.57 1.5-1.31 2.99-2.54 4.09l.01-.01zM12.03 7.25c-.15-2.23 1.66-4.07 3.74-4.25c.29 2.58-2.34 4.5-3.74 4.25z`})],-1),r(` `+m(e.$t(`start.downloadMacOS`)),1)])])),i(!1)?(d(),s(f,{key:5},[t[4]||=o(`p`,null,`\xA0`,-1),o(`p`,null,[o(`a`,{href:`#`,onClick:t[1]||=e=>Z()},m(e.$t(`start.deleteAll`)),1),t[3]||=r(` | `,-1),n(I,{test:``},{default:p(()=>[r(m(e.$t(`start.testPages`)),1)]),_:1})])],64)):v(``,!0),o(`p`,K,[t[5]||=o(`br`,null,null,-1),r(` `+m(i(N).app.release),1)])])]),_:1}))}});export{J as default};